home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gsmatrix.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.3 KB  |  85 lines

  1. /* Copyright (C) 1989, 1995, 1997, 1998 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gsmatrix.h,v 1.2 2000/09/19 19:00:29 lpd Exp $ */
  20. /* Definition of matrices and client interface to matrix routines */
  21.  
  22. #ifndef gsmatrix_INCLUDED
  23. #  define gsmatrix_INCLUDED
  24.  
  25. /* See p. 65 of the PostScript manual for the semantics of */
  26. /* transformation matrices. */
  27.  
  28. /* Structure for a transformation matrix. */
  29. #define _matrix_body\
  30.   float xx, xy, yx, yy, tx, ty
  31. struct gs_matrix_s {
  32.     _matrix_body;
  33. };
  34.  
  35. #ifndef gs_matrix_DEFINED
  36. #  define gs_matrix_DEFINED
  37. typedef struct gs_matrix_s gs_matrix;
  38. #endif
  39.  
  40. /* Macro for initializing constant matrices */
  41. #define constant_matrix_body(xx, xy, yx, yy, tx, ty)\
  42.   (float)(xx), (float)(xy), (float)(yx),\
  43.   (float)(yy), (float)(tx), (float)(ty)
  44.  
  45. /* Macros for testing whether matrix coefficients are zero, */
  46. /* for shortcuts when the matrix is simple. */
  47. #define is_xxyy(pmat) is_fzero2((pmat)->xy, (pmat)->yx)
  48. #define is_xyyx(pmat) is_fzero2((pmat)->xx, (pmat)->yy)
  49.  
  50. /* The identity matrix (for structure initialization) */
  51. #define identity_matrix_body\
  52.   constant_matrix_body(1, 0, 0, 1, 0, 0)
  53.  
  54. /* Matrix creation */
  55. void gs_make_identity(P1(gs_matrix *));
  56. int gs_make_translation(P3(floatp, floatp, gs_matrix *)),
  57.     gs_make_scaling(P3(floatp, floatp, gs_matrix *)),
  58.     gs_make_rotation(P2(floatp, gs_matrix *));
  59.  
  60. /* Matrix arithmetic */
  61. int gs_matrix_multiply(P3(const gs_matrix *, const gs_matrix *, gs_matrix *)),
  62.     gs_matrix_invert(P2(const gs_matrix *, gs_matrix *)),
  63.     gs_matrix_translate(P4(const gs_matrix *, floatp, floatp, gs_matrix *)),
  64.     gs_matrix_scale(P4(const gs_matrix *, floatp, floatp, gs_matrix *)),
  65.     gs_matrix_rotate(P3(const gs_matrix *, floatp, gs_matrix *));
  66.  
  67. /* Coordinate transformation */
  68. int gs_point_transform(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  69.     gs_point_transform_inverse(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  70.     gs_distance_transform(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  71.     gs_distance_transform_inverse(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  72.     gs_points_bbox(P2(const gs_point[4], gs_rect *)), gs_bbox_transform_only(P3(const gs_rect *, const gs_matrix *, gs_point[4])),
  73.     gs_bbox_transform(P3(const gs_rect *, const gs_matrix *, gs_rect *)),
  74.     gs_bbox_transform_inverse(P3(const gs_rect *, const gs_matrix *, gs_rect *));
  75.  
  76. /* Serialization */
  77. #ifndef stream_DEFINED
  78. #  define stream_DEFINED
  79. typedef struct stream_s stream;
  80. #endif
  81. int sget_matrix(P2(stream *, gs_matrix *));
  82. int sput_matrix(P2(stream *, const gs_matrix *));
  83.  
  84. #endif /* gsmatrix_INCLUDED */
  85.